package com.hp.his.basic.web;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.hp.his.basic.entity.UPMSIssue;
import com.hp.his.basic.entity.UPMSPage;
import com.hp.his.basic.service.UPMSBaseManager;
import com.hp.his.core.orm.Page;
import com.hp.his.core.util.web.struts2.CrudActionSupport;


/**
 *  @author danny
 * 
 */
@Namespace("/basic")
@Results({    
       @Result(name = CrudActionSupport.RELOAD, location = "issue.action", type = "redirect"),
})
public class IssueAction extends CrudActionSupport<UPMSIssue> {

	private static final long serialVersionUID = -4759322242590130177L;
	
	private UPMSIssue entity;
	
	private Integer issueId;
	
	@Autowired
	private UPMSBaseManager baseManager;
	private Page<UPMSIssue> page = new Page<UPMSIssue>(100);// 每页100条记录
	
	public Page<UPMSIssue> getPage() {
		return page;
	}
	
	public void setIssueId(Integer issueId) {
		this.issueId = issueId;
	}
	
	@Override
	public UPMSIssue getModel() {
		return entity;
	}
	@Override
	public String list() throws Exception {
		if (!page.isOrderBySetted()) {
			page.setOrderBy("issueId");
			page.setOrder(Page.ASC);
		}
		
		page = baseManager.getAllIssues(page);
		return SUCCESS;
	}
	@Override
	public String input() throws Exception {
		// TODO Auto-generated method stub
		return INPUT;
	}
	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	protected void prepareModel() throws Exception {
		if(issueId != null){
			entity = baseManager.getUPMSIssueById(issueId);
		} else {
			entity = new UPMSIssue();		
		}
	}

	
	
}
